package com.handinfo.android.game.item;

import android.graphics.Bitmap;

import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.graphics.DWGraphics;
import com.handinfo.android.game.Attribute;
import com.handinfo.android.game.IIcon;
import com.handinfo.android.ui.window.UIJiMingTai;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.utils.Tools;

public class Tianming implements IIcon
{

	public String key;
	public long m_guid;
	public byte qualityType;// 阶　，低 中 高 神
	public byte propertyType; //天命类型

	public byte whileCell; //装备在第几位
	public String name;

	public int level;

	public int hiddenHp;

	public int maxHp;

	public int maxML;

	public int currntML;

	public static final byte 低阶天命 = 1;
	public static final byte 中阶天命 = 2;
	public static final byte 高阶天命 = 3;
	public static final byte 神阶天命 = 4;

	/**
	 * 属性 增加
	 */
	public int addAttribute;
	/**
	 * 装备状态
	 */
	public byte position;

	/**
	 * mergepower 吞噬力
	 */
	public byte mergepower;

	public String getKey()
	{
		return key;
	}

	public void setKey(String key)
	{
		this.key = key;
	}

	public byte getQualityType()
	{
		return qualityType;
	}

	public void setQualityType(byte qualityType)
	{
		this.qualityType = qualityType;
	}

	public byte getPropertyType()
	{
		return propertyType;
	}

	public void setPropertyType(byte propertyType)
	{
		this.propertyType = propertyType;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public int getLevel()
	{
		return level;
	}

	public void setLevel(int level)
	{
		this.level = level;
	}

	public int getHiddenHp()
	{
		return hiddenHp;
	}

	public void setHiddenHp(int hiddenHp)
	{
		this.hiddenHp = hiddenHp;
	}

	public int getMaxHp()
	{
		return maxHp;
	}

	public void setMaxHp(int maxHp)
	{
		this.maxHp = maxHp;
	}

	public int getAddAttribute()
	{
		return addAttribute;
	}

	public void setAddAttribute(int addAttribute)
	{
		this.addAttribute = addAttribute;
	}

	public byte getPosition()
	{
		return position;
	}

	public void setPosition(byte position)
	{
		this.position = position;
	}

	public byte getMergepower()
	{
		return mergepower;
	}

	public void setMergepower(byte mergepower)
	{
		this.mergepower = mergepower;
	}

	public void setM_guid(long m_guid)
	{
		this.m_guid = m_guid;
	}

	public long getM_guid()
	{
		return m_guid;
	}

	public void setWhileCell(byte whileCell)
	{
		this.whileCell = whileCell;
	}

	public byte getWhileCell()
	{
		return whileCell;
	}

	public void drawIcon(DWGraphics g, int x, int y, int w, int h, int anchor)
	{
		int icon_w = 0;
		int icon_h = 0;
//		int tempX = 0;
//		int tempY = 0;
		Bitmap b = null;
		switch (propertyType) {
			case Attribute.PHY_ATTACK:
				b = UIJiMingTai.m_jmtBitmap03[0];
				break;
			case Attribute.PHY_DEFENSE:
				b = UIJiMingTai.m_jmtBitmap03[1];
				break;
			case Attribute.MAG_ATTACK:
				b = UIJiMingTai.m_jmtBitmap03[2];
				break;
			case Attribute.MAG_DEFENSE:
				b = UIJiMingTai.m_jmtBitmap03[3];
				break;
			case Attribute.MAX_HP:
				b = UIJiMingTai.m_jmtBitmap03[4];
				break;
			case Attribute.HIT:
				b = UIJiMingTai.m_jmtBitmap03[5];
				break;
			case Attribute.DODDGE:
				b = UIJiMingTai.m_jmtBitmap03[6];
				break;
			case Attribute.CRIT:
				b = UIJiMingTai.m_jmtBitmap03[7];
				break;
			case Attribute.CRIT_DEF:
				b = UIJiMingTai.m_jmtBitmap03[8];
				break;
			case Attribute.CRIT_DAMAGE_INC:
				b = UIJiMingTai.m_jmtBitmap03[9];
				break;
			case Attribute.CRIT_DAMAGE_DEC:
				b = UIJiMingTai.m_jmtBitmap03[10];
				break;
		}
		g.drawBitmap(b, x, y, anchor);
		drawName(g, x, y, w, h);
	}

	public void drawIcon(DWGraphics g, int x, int y, int w, int h, float w1, float h1, int anchor)
	{
		int icon_w = 0;
		int icon_h = 0;
		int tempX = x;
		int tempY = y;
		Bitmap b = null;
		switch (propertyType) {
			case Attribute.PHY_ATTACK:
				b = UIJiMingTai.m_jmtBitmap03[0];
				break;
			case Attribute.PHY_DEFENSE:
				b = UIJiMingTai.m_jmtBitmap03[1];
				break;
			case Attribute.MAG_ATTACK:
				b = UIJiMingTai.m_jmtBitmap03[2];
				break;
			case Attribute.MAG_DEFENSE:
				b = UIJiMingTai.m_jmtBitmap03[3];
				break;
			case Attribute.MAX_HP:
				b = UIJiMingTai.m_jmtBitmap03[4];
				break;
			case Attribute.HIT:
				b = UIJiMingTai.m_jmtBitmap03[5];
				break;
			case Attribute.DODDGE:
				b = UIJiMingTai.m_jmtBitmap03[6];
				break;
			case Attribute.CRIT:
				b = UIJiMingTai.m_jmtBitmap03[7];
				break;
			case Attribute.CRIT_DEF:
				b = UIJiMingTai.m_jmtBitmap03[8];
				break;
			case Attribute.CRIT_DAMAGE_INC:
				b = UIJiMingTai.m_jmtBitmap03[9];
				break;
			case Attribute.CRIT_DAMAGE_DEC:
				b = UIJiMingTai.m_jmtBitmap03[10];
				break;
		}
		g.drawBitmap(b, tempX, tempY, (int) (b.getWidth() * w1), (int) (b.getHeight() * h1), anchor);
//		drawName(g, tempX, tempY, (int) (b.getWidth() * w1), (int) (b.getHeight() * h1));
	}

	public static String getTianMType(byte type)
	{
		String typeName = null;
		switch (type) {
			case Attribute.PHY_ATTACK:
				typeName = Attribute.ATTRIBUTE_NAME[7];
				break;
			case Attribute.PHY_DEFENSE:
				typeName = Attribute.ATTRIBUTE_NAME[9];
				break;
			case Attribute.MAG_ATTACK:
				typeName = Attribute.ATTRIBUTE_NAME[8];
				break;
			case Attribute.MAG_DEFENSE:
				typeName = Attribute.ATTRIBUTE_NAME[10];
				break;
			case Attribute.MAX_HP:
				typeName = Attribute.ATTRIBUTE_NAME[0];
				break;
			case Attribute.HIT:
				typeName = Attribute.ATTRIBUTE_NAME[11];
				break;
			case Attribute.DODDGE:
				typeName = Attribute.ATTRIBUTE_NAME[12];
				break;
			case Attribute.CRIT:
				typeName = Attribute.ATTRIBUTE_NAME[13];
				break;
			case Attribute.CRIT_DEF:
				typeName = Attribute.ATTRIBUTE_NAME[14];
				break;
			case Attribute.CRIT_DAMAGE_INC:
				typeName = Attribute.ATTRIBUTE_NAME[16];
				break;
			case Attribute.CRIT_DAMAGE_DEC:
				typeName = Attribute.ATTRIBUTE_NAME[15];
				break;
		}
		return typeName;
	}

	private DWFont m_font = DWFont.getFont(15);

	public void drawName(DWGraphics g, int x, int y, int w, int h)
	{
		int tempX = x - (w >> 1);
		int tempY = y + ((h - m_font.getHeight()) / 8);

		String temp = name;
		g.drawShadowString(m_font, temp, DWControlsManager.COLOR_STROKE, getTianming_Color(qualityType), tempX, tempY,
				Tools.LEFT_TOP);

	}

	/**
	 * 获取天命品阶对应颜色....图标上显示用
	 * @param qualityType
	 * @return
	 */
	public int getTianming_Color(int qualityType)
	{
		int color = 0;
		if (qualityType >= 0) {
			switch (qualityType) {
				case 低阶天命:
					color = 0xFFFFFFFF;
					break;
				case 中阶天命:
					color = 0xFF00BBFF;
					break;
				case 高阶天命:
					color = 0xFF9900FF;
					break;
				case 神阶天命:
					color = 0xFFFFBB11;
					break;
			}
		}
		return color;
	}

	/**
	 * 金钱转换 如果金钱大于1W将转换成以万为单位
	 * @param money
	 * @return
	 */
	public static String getMoney(long money)
	{
		String temp = null;
		if (money > 9999) {
			temp = String.valueOf(money / 10000).concat("万");
		}
		else {
			temp = String.valueOf(money);
		}
		return temp;
	}

	/**
	 * 获取天命品阶
	 * @param qualityType
	 * @return
	 */
	public static String getTianmingLevel(int qualityType)
	{
		String name = "";
		if (qualityType >= 0) {
			switch (qualityType) {
				case 低阶天命:
					name = "低阶天命";
					break;
				case 中阶天命:
					name = "中阶天命";
					break;
				case 高阶天命:
					name = "高阶天命";
					break;
				case 神阶天命:
					name = "神阶天命";
					break;
			}
		}
		return name;
	}

	/**
	 * 获取天命品阶对应颜色
	 * @param qualityType
	 * @return
	 */
	public static String getTianmingColor(int qualityType)
	{
		String color = "";
		if (qualityType >= 0) {
			switch (qualityType) {
				case 低阶天命:
					color = "FFFFFF";
					break;
				case 中阶天命:
					color = "00BBFF";
					break;
				case 高阶天命:
					color = "9900FF";
					break;
				case 神阶天命:
					color = "FFBB11";
					break;
			}
		}
		return color;
	}
}
